Binary Viruses Investigation Committee detected, that certain sequences of zeroes and ones are codes of viruses. The committee isolated a set of all the virus codes. A sequence of zeroes and ones is called safe, if any of its segments (i.e. sequence of consecutive elements) is not a virus code. The committee is aiming at finding, whether an infinite, safe sequence of zeroes and ones exists.
Example
For a set of codes , the sample infinite safe sequence is For a set of codes an infinite safe sequence of zeroes and ones does not exist.
Task
Write a program, which:
reads from the standard input virus codes,
determines, whether an infinite, safe sequence of zeroes and ones exists
writes the result to the standard output.
Input
The first line of the standard input consists of one integer standing for the number of all virus codes. Each of the next lines consists of one non-empty word composed from 0s and 1s - a virus code. The total length of all words does not exceed 30000.
Output
In the first and the only line of the standard output one should find a word:
TAK - if an infinite, safe sequence of zeroes and ones exists.
NIE - otherwise.
Example
For the input data:
3
01
11
00000
the correct result is:
NIE
Task author: Wojciech Rytter.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.